package com.example.demo.system.controller;

import com.example.demo.system.entity.Dept;
import com.example.demo.system.service.DeptService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
/**
* @author 许久龙
* @since 2022-02-19
*/
@RestController
@RequestMapping("api")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @GetMapping("/dept")
    @ApiOperation("Dept查询单个")
    public ResultVO getDept(@RequestBody Dept dept){
     ResultVO resultVO = deptService.getDept(Dept dept);
     return  resultVO;
   }

    @GetMapping("/dept")
    @ApiOperation("Dept查询全部")
    public ResultVO getAllDept(){
        ResultVO resultVO = deptService.getAllDept();
        return  resultVO;
    }

    @PostMapping("/dept")
    @ApiOperation("Dept新增")
    public ResultVO add(@Valid @RequestBody Dept dept) {
        ResultVO resultVO = deptService.add(Dept dept);
        return  resultVO;
    }

    @PutMapping("/dept")
    @ApiOperation("Dept修改")
    public ResultVO update(@Valid @RequestBody Dept dept) {
        ResultVO resultVO = deptService.update(Dept dept);
        returnresultVO;
    }


    @DeleteMapping(value = "/dept/{ids}")
    @ApiOperation("Dept删除(单个条目)")
    public ResultVO remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        ResultVO resultVO = deptService.remove(String ids);
        return resultVO;
    }
}
